<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <title><?php echo $this->page_title; ?></title>
    <link rel="stylesheet" type="text/css" href="/style/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="/style/css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="/style/css/xshop.css?ver=20180728" />
    <script src="/style/js/jquery-1.12.0.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/style/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/style/js/xShop.js" type="text/javascript" charset="utf-8"></script>
    </head>
<body>
<div class="outwrap">
  <!--top-->
  <!-- <div class="topbar clearfix topvh">
    <a href="/myshop/my_bag" class="btn-back">
      <i class="ico-back"></i><span>提现申请</span>
    </a>
  </div> -->
  <form id="form_tx">
  <div class="meinner-adr-add">

    <div class="tixian-edu">
      <p class="kt"> 可提现硒豆：<span><?=$this->balance['revenue'] <= $this->balance['money'] ? $this->balance['revenue'] : $this->balance['money'];?></span></p>
    </div>

    <div class="tixian-minf mt20">      
    <dl class="clearfix">
        <dt>提现类型：</dt>
        <dd>
          <div class="srhbank">
            <div class="sortslt"><span>银行卡</span>
              <select name="withdraw_type" id="_withdraw_type">
                <option value="2" selected="selected">银行卡</option>
                <option value="1">微信零钱</option>
              </select>
            </div>
           
          </div>
        </dd>
      </dl>
    
    
      <dl class="clearfix">
        <dt>提现硒豆数量：</dt>
        <dd>
          <input type="text" class="txt"  name="money" id="_money"/>
        </dd>
      </dl>
      <dl class="clearfix _bank">
        <dt>提现银行：</dt>
        <dd>
          <div class="srhbank">
            <div class="sortslt"><span>选择银行</span>
              <select name="bank" id="bank">
              <option value="">请选择银行</option>
                <?php foreach ($this->bank as $v): ?>
                <option value="<?=$v['id']?>"><?=$v['bank_name']?></option>
              <?php endforeach;?>

              </select>
            </div>
            <a href="add_bank?type=1"  class="go-add">去添加</a>
          </div>
          <p id="bank_account"></p>
          <p id="bank_number"></p>
        </dd>
      </dl>
      <!-- <dl class="clearfix">
        <dt>验&nbsp;证&nbsp;码&nbsp;：&nbsp;</dt>
        <dd style="margin-left: -0.04rem;">
          <input type="text" class="txt2" name="verfy_code" id="verfy_code"/>
          <span class="yzm"><img src="/verify?<?=$_SERVER['REQUEST_TIME'];?>" id="verfyimg"></span>          
        </dd>
      </dl>
       -->
       <dl class="clearfix">
        <dt>手&nbsp;续&nbsp;费&nbsp;：&nbsp;</dt>
        <dd style="margin-left: -0.04rem;">
           <span id="trade_fee"></span>
        </dd>
      </dl>
      <dl class="clearfix">
        <dt>实得金额： </dt>
        <dd style="margin-left: -0.04rem;">
          <span id="pay_price"></span>
        </dd>
      </dl>
    </div>

    <div class="tixian-edu mt20">
      <p class="sm">提现说明：<br>
        1-可用硒豆在【T+<?=$this->getSetting['moneytransfer'];?>日】之后，到“可提现硒豆”钱包；<br>
        2-提现数量<?=$this->getSetting['min_withdraw_money']?>起，提现手续费<?=$this->getSetting['withdraw_percent'] * 100?>%（最低<?=$this->getSetting['min_withdraw_charge']?>元）。
      </p>
    </div>

    <div class="btnwrap">
    <input type="hidden" value="<?=$this->data['revenue'] > 0 ? $this->data['revenue'] : 0;?>" id="c">
      <input type="button" class="btn-mexl btn-bc"  id="submit_tx" value="申请" />
    </div>
  </div>
</form>
</div>
<link rel="stylesheet" href="/style/css/sweet-alert.css" />
<script type="text/javascript" src="/style/js/sweet-alert.min.js"></script>
<script type="text/javascript">
var _min = <?=$this->getSetting['min_withdraw_money']?>,
    _min_charge = <?=$this->getSetting['min_withdraw_charge']?>,
    _amount = <?=$this->balance['revenue'] <= $this->balance['money'] ? $this->balance['revenue'] : $this->balance['money'];?>,
    c = <?=$this->getSetting['withdraw_percent']?>;

$(document).ready(function(e) {

  $("#verfyimg").bind("click",function(){
    $("#verfyimg").prop("src", "/verify?mr=" + Math.random());
  });

    $('#_withdraw_type').change(function() {
        var withdraw_type = $(this).val();
        if(withdraw_type==1){
				$('._bank').hide();
            }else{

            	$('._bank').show();
             }
       
    });


    $('.sortslt select').change(function() {
        var thisTxt = $(this).find('option:selected').text();
        $(this).prev('span').text(thisTxt);
        bid = $("#bank").val();
        $.post("ajax", {
            act: "get_bank_info",
            bid: bid
        }, function(data) {
            if (data.code = 200) {
                $("#bank_account").html("姓名：" + data.info.account_name);
                $("#bank_number").html("卡号：" + data.info.card_number);
            }
        }, 'json');
    });
    $('.psfs span').on('click', function() {
        $(this).addClass('on').siblings().removeClass('on');
    });
    $("#_money").bind("input propertychange",function(event){
        var money = parseInt($("#_money").prop("value"));
        
        if(money){
            var p = (money * c).toFixed(2);
            if(p<_min_charge)
            {
              p = _min_charge.toFixed(2);
            }
            var sf = (money - p).toFixed(2);
        
                if(sf<=0){
                	sf = 0;
                }
    
    
            $('#trade_fee').html(p);
            $('#pay_price').html(sf);

        }
    });
    $("#submit_tx").click(function() {
        var money = parseInt($("#_money").prop("value"));
        if ($("#_money").val() == "") {
            swal("请输入提现金额");
            return false;
        } else {
            if (!$.isNumeric($("#_money").val())) {
                swal("提现金额必须是数字");
                return false;
            }
        }

  
        if (money < _min) {
            swal("金额不能少于" + _min + "元");
            return false;
        } else if (money > _amount) {
            swal("金额不能大于可用余额");
            return false;
        }  
        if ($('#_withdraw_type').val()==2) {

            if($("#bank").val() == ""){
            	swal("请选择银行");
                return false;
                }
            
        }

        if ($("#verfy_code").val() == "") {
            swal("请输入验证码");
            return false;
        } else {
           
            $.ajax({
                type: 'post',
                url: 'ajax_pickup',
                data: $("#form_tx").serialize() + "&mr=" + Math.random(),
                dataType: 'json',
                success: function(data) {
                    if (data != "") {
                        if (data.code == 200) {
                            swal("申请提现成功！", '请等待我们为您处理', "success");
                            setTimeout(function(){
                              window.location.href = '/wallet';
                            },2000);
                        } else {
                       	    swal('提现失败，请重试！['+data.code+']');
                        }
                    }
                }
            });
        }
    });
});
</script>

<!--底部导航-->

</body>
</html>
